//
// Created by wkm on 2024-03-17.
//

#include "AddRoundKey.h"

//定义轮密钥加操作
void AddRoundKey(unsigned char *col, unsigned char *expansionkey, int round)//密匙加
{
    //扩展密钥：44*32bit =11*4* 4*8 =  16字节*11轮，每轮用16字节密钥
    //第0轮，只进行一次轮密钥加
    //第1-10轮，轮密钥加
    int x;
    for (x = 0; x < 16; x++) {    //每1轮操作：4*32bit密钥 = 16个字节密钥
        // round << 4 即为 round * 16
        col[x] ^= expansionkey[(round << 4) + x];
    }
}


//void addRoundKey::prc_addRoundKey() {
//    sc_biguint<WIDTH> inKeyOpd, resultKey;
//    sc_uint<4> round;
//
//    inKeyOpd = inKey.read();
//
//    round = 0;
//    for (round = 0; round < 11; ++round) {
//        int x;
//        for (x = 0; x < 16; x++) {    //每1轮操作：4*32bit密钥 = 16个字节密钥
//            col[x] ^= resultKey[(round << 4) + x];
//        }
//    }
//
//    outKey = resultKey;
//}
